﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once        
#include "IFamilyEntity.h"
#include "GmFamilyService.h"
#include "FamilyConstraintType.h"
#include "ElementCreationOptions.h"

namespace gfam
{

    /// \brief  通用约束基类
    class GM_FAMILY_SERVICE_EXPORT IFamilyConstraint : public IFamilyEntity
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyConstraint, gfam::IFamilyEntity)
    public:

        /// \brief 获取坐标系
        ///
        /// \return 有关联平面时返回关联平面的坐标系,否则返回设置的坐标系
        virtual gcmp::Coordinate3d GetCoordinate() const = 0;

        /// \brief 设置坐标系
        ///
        /// \param coordinate 设置新的坐标系
        virtual void SetCoordinate(const gcmp::Coordinate3d& coordinate) = 0;

        /// \brief 获取关联平面id (草图平面或者参照平面)
        ///
        /// \return 关联平面id
        virtual gcmp::ElementId GetAssociatedPlaneId() const = 0;
        
        /// \brief 设置关联平面id (草图平面或者参照平面)
        ///
        /// \param planeId 关联平面id
        virtual void SetAssociatedPlaneId(const gcmp::ElementId& planeId) = 0;

        /// \brief 获取所属草图id 
        ///
        /// \return 草图id
        virtual gcmp::ElementId GetSketchId() const = 0;

        /// \brief 设置所属草图id
        ///
        /// \param sketchId 草图id
        /// \return 设置成功返回true,否则返回false
        virtual bool SetSketchId(const gcmp::ElementId& sketchId) = 0;

        /// \brief 获取关联平面的关联更新id
        ///
        /// \return 关联更新id
        virtual RegenDataId GetAssociatedPlaneIdRdId() const = 0;

        /// \brief 获取引用对象的关联更新id
        ///
        /// \return 关联更新id
        virtual RegenDataId GetReferenceObjectsRdId() const = 0;

        /// \brief 设置引用对象
        ///
        /// \param  referenceObjects 引用的对象
        virtual void SetReferenceObjects(std::vector<gcmp::OwnerPtr<gcmp::IGraphicsNodeReference>>& referenceObjects) = 0;

        /// \brief 获取所有引用对象
        ///
        /// \return 返回所有引用对象
        virtual std::vector<gcmp::OwnerPtr<gcmp::IGraphicsNodeReference>>& GetReferenceObjectsFW() = 0;

        /// \brief 获取所有引用对象
        ///
        /// \return 返回所有引用对象
        virtual const std::vector<gcmp::OwnerPtr<gcmp::IGraphicsNodeReference>>& GetReferenceObjects() const = 0;

        /// \brief 添加引用对象
        ///
        /// \param referenceObject 引用对象
        /// \return 返回true表示添加成功，否则返回false
        /// \note 不同约束支持引用的对象类型和个数一般会不同
        virtual bool AddReferenceObject(gcmp::OwnerPtr<gcmp::IGraphicsNodeReference> referenceObject) = 0;

        /// \brief 获取约束是否引用了某个Element
        ///
        /// \param id 指定的Element id
        /// \return 返回true表示引用了此Element，否则返回false
        virtual bool IsElementReferenced(const gcmp::ElementId &id) const = 0;

        /// \brief 获取草图外是否可见
        ///
        /// \return 草图外可见返回true，否则返回false
        virtual bool IsVisibleOutOfSketch() = 0;

        /// \brief 设置草图外是否可见
        ///
        /// \param visibleOutSketch 草图外约束是否可见
        virtual void SetVisibleOutOfSketch(bool visibleOutOfSketch) = 0;

        /// \brief 获取约束类型
        ///
        /// \return 约束类型
        virtual FamilyConstraintType GetConstraintType() const = 0;

        /// \brief 获取所属的约束组id
        ///
        /// \return 约束组id
        virtual gcmp::ElementId GetConstraintGroupId() const = 0;

        /// \brief 获取约束值(大部分情况是在约束解算时使用)
        ///
        /// \return 约束值
        virtual double GetValue() const = 0;

        /// \brief 设置主对象的Id
        /// 主对象指具有强依赖关系的对象，当主对象被删除时，从对象也会被删除。
        ///
        /// \param masterId 主对象Id
        /// \return void
        virtual void SetMasterId(gcmp::ElementId masterId) = 0;
    };
}